public class PirateTreasure {
	public double getDistance(int[] steps, String[] directions) {
		double x=0.0,y=0.0,result=0.0;
		double a=0.0,b=0.0,c=0.0,d=0.0;
		int num=directions.length;
		for(int i=0;i<num;i++){
		  System.out.println("i="+i);
		  int step=steps[i];
		  String direction=directions[i];
		  if(direction.equals("NORTH"))x=x+step;
		  else if(direction.equals("SOUTH"))x=x-step;
		  else if(direction.equals("EAST"))y=y+step;
		  else if(direction.equals("WEST"))y=y-step;
		  else if(direction.equals("NORTHEAST"))a=a+step;
		  else if(direction.equals("NORTHWEST"))b=b+step;
		  else if(direction.equals("SOUTHEAST"))c=c+step;
		  else if(direction.equals("SOUTHWEST"))d=d+step;
		  System.out.println("x="+x+" y="+y);
	   }
	   if(x==0 && y==0)result=Math.sqrt(a*a+b*b);
	   else if(a==0 && b==0)result=Math.sqrt(x*x+y*y);
	   else result=Math.sqrt((x+(a+b-c-d)/Math.sqrt(2))*(x+(a+b-c-d)/Math.sqrt(2))+(y+(a+c-b-d)/Math.sqrt(2))*(y+(a+c-b-d)/Math.sqrt(2)));
	   return result;
	   }
	public static void main(String args[]){
		PirateTreasure a=new PirateTreasure();
		int[] steps={2};
		String[] directions={"NORTHEAST"};
		System.out.println(a.getDistance(steps,directions));
	}
}